﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FF.Entity;
using FF.Method;

namespace FF
{
    public partial class FormUserSelect : Form
    {
        public FormUserSelect()
        {
            InitializeComponent();
        }

        private void FormUserSelect_Load(object sender, EventArgs e)
        {
            UserMethod.fillUser(treeView1, imageList1);
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(treeView1.SelectedNode.Level.ToString());
            if (treeView1.SelectedNode.Level == 0)
            {
                MessageBox.Show("请选择一个用户");
                return;
            }
            else if (treeView1.SelectedNode.Level == 1)
            {
                //MessageBox.Show(treeView1.SelectedNode.Text);
                //MessageBox.Show(treeView1.SelectedNode.Name);
                FormCustomer frm = (FormCustomer)this.Owner;
                frm.textBoxUsername.Text = treeView1.SelectedNode.Text;
                frm.userId = treeView1.SelectedNode.Name;
                frm.userName = treeView1.SelectedNode.Text;
                this.Close();
                return;
            }
        }

        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            //MessageBox.Show(treeView1.SelectedNode.Level.ToString());
            buttonOK_Click(sender,e);
        }
    }
}
